import logging
import redis


class Config(object):
    '''项目配置信息类'''

    # sqlalchemy数据库扩展配置信息,方便python与mysql交互,减少代码量
    SQLALCHEMY_DATABASE_URI = 'mysql://root:mysql@192.168.5.128:3306/news'
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    # redis 数据库配置信息
    REDIS_HOST = '127.0.0.1'
    REDIS_PORT = 6379

    SECRET_KEY = 'EjpNVSNQTyGi1VvWECj9TvC/+kq3oujee2kTfQUs8yCM6xX9Yjq52v54g+HVoknA'
    # session储存的信息配置
    SESSION_TYPE = redis  # 指定session保存到redis中
    SESSION_USE_SIGNER = True  # 让cookie中的session_id 被加密签名处理
    SESSION_REDIS = redis.StrictRedis(host=REDIS_HOST, port=REDIS_PORT, db=1)  # 使用redis 实例
    PERMANENET_SESSION_LIFETIME = 86400  # 指定session'的有效时间,单位是秒


class DevelopmentConfig(Config):
    DEBUG = True
    LOG_LEVEL = logging.DEBUG


class ProductionConfig(Config):
    LOG_LEVEL = logging.WARNING


config_dict = {
    'development': DevelopmentConfig,
    'production': ProductionConfig
}
